#ifndef GRITC_SERVER_BRUTE_HPP
#define GRITC_SERVER_BRUTE_HPP

#include <gritc/server/buff.hpp>

namespace gritc { namespace server {

	struct setup_brute_
	{
		template<class M> void operator()(M & m) const
		{
			m.power 	= 50;
			m.endurance = 50;
			m.haste 	= 50;
			m.vitality	= 50;
			m.grace		= 50;

			m.hp = m.endurance * 10;
			m.soak = 0;
		}
	} const setup_brute;

	template<class Traits> struct wild_swing_buff
	{
		typedef typename Traits traits_type;
		typedef typename Traits::string_type string_type;
		typedef typename Traits::damage_type damage_type;
		typedef typename Traits::buffor_type buffor_type;
		typedef typename Traits::null_effect_type null_effect_type;


		struct applier
		{
			template<class E> void operator ()(E & e)
			{
				typedef E::actor_type Actor;
				typedef Actor::buff_type Buff;

				if(e.out_bit)
					return;

				Buff * buff_ = new_buff("wild_swing_buff", wild_swing_buff<Traits>());
				e.target().buffs().push_back(buff_);

				buff_->ttl = 7000;

				e.target().room().response()
					<<	" "
					<< 	e.name()
					<<	" stacks 1 ttl 7000 ";
			}
		};

		long stacks;

		wild_swing_buff() :	stacks(1) {}

		template<class B, class E> void operator()(B & b, E & e, damage_type & d)
		{
			if(d.out_bit)
				d.ammount = (long)(0.10f * stacks * d.ammount) + d.ammount;
			else
				d.ammount = (long)(0.05f * stacks * d.ammount) + d.ammount;
		}
		template<class B, class E> void operator()(B & b, E & e, buffor_type & t)
		{
			if(b.name() == "wild_swing_buff" && t.out_bit)
			{
				if(stacks < 5) ++stacks;
				b.ttl = 7000;
				t.source().room().response() << " wild_swing_buff ttl 7000 stacks " << stacks << " ";
				e.reset(new_effect(null_effect_type()));
			}
		}
		template<class B, class E, class T> void operator()(B & b, E & e, T & t) {}
	};

	struct wild_swing_command_
	{
		template<class W, class A, class I> void operator()(W & w, A & a, I b, I e) const
		{
			typedef A::traits_type Traits;

			static const W::string_type ws_str("wild_swing");
			static const W::string_type wsb_str("wild_swing_buff");
			
			gritc::server::apply_buff(wsb_str, w, a, a, wild_swing_buff<Traits>::applier());
			gritc::server::apply_damage(ws_str, w, a, a.target(), a.power);
		}
	} const wild_swing_command;
}}

#endif